package util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URLConnection;
import java.nio.channels.FileChannel;

public class FileOperator {

    public static void copyFile(String file1, String file2) throws IOException {
        copyFile(new File(file1), new File(file2));
    }
    
    public static void copyFile(File file1, File file2) throws IOException {
        FileChannel srcChannel = new FileInputStream(file1).getChannel();
        FileChannel dstChannel = new FileOutputStream(file2).getChannel();

        dstChannel.transferFrom(srcChannel, 0, srcChannel.size());

        srcChannel.close();
        dstChannel.close();
    }
    
    public static String getMimeType(String file) {
        return URLConnection.getFileNameMap().getContentTypeFor(file);
    }
    
    
}
